import React, { Component } from 'react'
import { LocaleProvider } from 'antd'
import { IntlProvider } from 'react-intl'
import locales from './locales'
import { connect } from 'react-redux'
import Home from './Home/index'
import { getLangFromLocalStorage } from './constant/lang-util'

class App extends Component {
  render () {
    const lang = this.props.lang || getLangFromLocalStorage()
    const langData = locales[lang]
    return (
      <IntlProvider locale={langData.intlLocale} messages={langData.intlMessage}>
        <LocaleProvider locale={langData.locale}>
          <Home />
        </LocaleProvider>
      </IntlProvider>

    )
  }
}

const mapStateToProps = ({ lang }) => ({ lang })

export default connect(mapStateToProps)(App)
